﻿Imports System
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Partial Public Class Thorbber
    Dim RedStory, BlueStory, GreenStory, GoldStory As Storyboard
    Dim PlayAni As Boolean
    Public Sub New()
        MyBase.New()
        Me.InitializeComponent()
        RedStory = DirectCast(Me.Resources("RARed"), Storyboard)
        AddHandler RedStory.Completed, AddressOf RedFinished
        BlueStory = DirectCast(Me.Resources("RABlue"), Storyboard)
        AddHandler BlueStory.Completed, AddressOf BlueFinished
        GreenStory = DirectCast(Me.Resources("RAGreen"), Storyboard)
        AddHandler GreenStory.Completed, AddressOf GreenFinished
        GoldStory = DirectCast(Me.Resources("RAGold"), Storyboard)
        AddHandler GoldStory.Completed, AddressOf GoldFinished
        PlayAni = True
    End Sub
    Public Sub StopMe()
        PlayAni = False
    End Sub
    Public Sub StartAnimation()
        If PlayAni = True Then
            RedStory.Begin(Me)
        End If
    End Sub
    Private Sub RedFinished(ByVal sender As Object, ByVal e As EventArgs)
        GreenStory.Begin(Me)
    End Sub
    Private Sub GreenFinished(ByVal sender As Object, ByVal e As EventArgs)
        BlueStory.Begin(Me)
    End Sub
    Private Sub BlueFinished(ByVal sender As Object, ByVal e As EventArgs)
        GoldStory.Begin(Me)
    End Sub
    Private Sub GoldFinished(ByVal sender As Object, ByVal e As EventArgs)
        StartAnimation()
    End Sub
    Public WriteOnly Property StatusText() As String
        Set(ByVal value As String)
            message.Content = value
        End Set
    End Property
End Class
